/*
    对象
*/

var myCar = new Object();

console.log(myCar);

myCar.model = "Mustang";

console.log(myCar);

console.log(myCar.year);

function Person() {
    this.name = "zhangsan";

}

let person = new Person();

console.log(person);

person.age = 18;

console.log(person);

// for (i in person) {
//     console.log(i);
// }

console.log(person.hasOwnProperty("name"));
console.log(person.hasOwnProperty("hobby"));

var myHonda = { color: "red", wheels: 4, engine: { cylinders: 4, size: 2.2 } };

// console.log(typeof myHonda);


console.log(Person.prototype); // Object
// 对象.属性
console.log(person.__proto__);
console.log(myHonda.__proto__);


// Student 构造
function Student() { }

let stu = new Student();
stu.__proto__ = Person;

console.log(stu);

// let f = function () {
//     this.a = 1;
//     this.b = 2;
// }

// let o = new f(); // {a: 1, b: 2}

// console.log(o);


// f.prototype.b = 3;
// f.prototype.c = 4;

// console.log(o.a);  // 1
// console.log(o.b); // 2
// console.log(o.c); // 4
// console.log(o.d); // undefined